import router from '@/router'

function has(auths, permission) {
  permission = permission.replace(/["]/g, '')
  return auths.some(auth => auth.indexOf(permission) >= 0)
}
//test branchs
const auth = {
  bind: function(el, binding) {
    const auths = router.currentRoute.meta.auth
    var s = JSON.stringify
    if (!has(auths, s(binding.value))) {
      el.remove()
    }
  }
}
const install = function(Vue) {
  Vue.directive('auth', auth)
}
auth.install = install
export default auth

